<?php
    require APPPATH .'third_party/admin_controller'.EXT;
    class Order extends Admin_Controller
    {
		public function __construct()
		{
			parent::__construct();
		}
        public function index()
        {
            $data = array();
            $data['list_order'] = $this->order_model->list_order();
            $this->load_render($this->load->view('order/list',$data,TRUE));
        }
        function update()
        {
            
            $data = array();
            $id = $this->input->post('id');
            $data['active'] = $this->input->post('type');
            if($this->order_model->update_active($id,$data))
            {
                $data['status'] = 'Cập nhật thành công';
            }           
            echo json_encode($data);
        }        
        function delete_order()
        {
            $id = $this->uri->segment('4');            
            if($this->order_model->delete_order($id))
            {
               redirect('admin/order/');
            }
             
           
        }
        function get_id()
        {
            $html = '';
            $id = $this->uri->segment('4');
            $q = $this->order_model->get_order($id);
           
    	$html .= '<table style="padding:5px; border:1px solid #ccc; width:600px;">';    
        	$html .= '<tr>';
            	$html .= '<td colspan="2" style="color:white; padding:5px 10px; text-align:center; margin-bottom:5px; background:red;">Thông tin khách hàng</td>';
               
            $html .= '</tr>';  
                	
        	$html .= '<tr>';
            	$html .= '<td>Họ và tên: </td>';
                $html .= '<td>'.$q->fullname.'</td>';
            $html .= '</tr>';   
            $html .= '<tr>';
            	$html .= '<td>Sản phẩm :</td>';
                $html .= '<td>'.$this->product_model->get_name_product($q->id_product).'</td>';
            $html .= '</tr>';   
            $html .= '<tr>';
            	$html .= '<td>Số lượng :</td>';
                $html .= '<td>'.$q->soluong.'</td>';
            $html .= '</tr>';  
            $html .= '<tr>';
            	$html .= '<td> Ngày đặt hàng: </td>';
                $html .= '<td>'.$q->date_order.'</td>';
            $html .= '</tr>';     
            $html .= '<tr>';
            	$html .= '<td>Địa chỉ: </td>';
                $html .= '<td>'.$q->address.'</td>';
            $html .= '</tr>';       
            $html .= '<tr>';
            	$html .= '<td>Số điện thoại: </td>';
                $html .= '<td>'.$q->phone.'</td>';
            $html .= '</tr>';  
            $html .= '<tr>';
            	$html .= '<td>Ghi chú: </td>';
                $html .= '<td>'.$q->comment.'</td>';
            $html .= '</tr>'; 
        $html .= '</table>';
        echo $html;
            
        }
    }
?>    